package com.jinxin.platform.cdacscontrolmgr.task;

import com.jinxin.platform.cdacscontrolmgr.bean.CdacscontrolmgrRegistInfo;
import com.jinxin.platform.cdacscontrolmgr.common.Constant;
import com.jinxin.platform.cdacscontrolmgr.mapper.CdacscontrolmgrRegistInfoMapper;
import com.jinxin.platform.cdacscontrolmgr.rpc.CdacscontrolmgrRpc;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.util.TimerTask;

/**
 * @Author 那个男人
 * @Date 2022/4/15 14:07
 * @Version 1.0
 */
@AllArgsConstructor
@Slf4j
public class PortraitDeleteTask extends TimerTask {
    private final CdacscontrolmgrRpc cdacscontrolmgrRpc;
    private final CdacscontrolmgrRegistInfoMapper registInfoMapper;
    private final String peronId;
    private final String projectId;

    @Override
    public void run() {
        log.info("删除人脸和更新状态任务执行开始");
        String id = this.peronId;
        this.cdacscontrolmgrRpc.deletePortraitData(id,projectId);
        CdacscontrolmgrRegistInfo regInfo = this.registInfoMapper.selectByKey(id);
        if(regInfo != null && Constant.REGIST_INFO_STATUS_NEW.equals(regInfo.getStatus())){
            CdacscontrolmgrRegistInfo registInfo = new CdacscontrolmgrRegistInfo();
            registInfo.setId(id);
            registInfo.setStatus(Constant.ACS_REGIST_NOT_COME);
            this.registInfoMapper.updateByKey(registInfo);
        }
        log.info("删除人脸任务执行结束");
    }
}
